package com.myself.community.entity;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.Setting;

import java.util.Date;

@Data
//es 7.0需注意地方 shards ,replicas 在document弃用，改用setting注入
@Setting(shards = 6,replicas = 3)//分片6，副本存3份
@Document(indexName = "discusspost"/*,shards = 6,replicas = 3*/) //索引名字
public class DiscussPost {

    //主键
    @Id        //主键，sping将其映射到主键_id上
    private int id;

    //用户id
    @Field(type = FieldType.Integer)  //与es字段对应
    private int userId;

    //帖子标题
    //analyzer = "ik_max_word":存储时，拆分出足够多的词；
    //searchAnalyzer = "ik_smart"：搜索时，拆分尽可能少但是满足需要的词
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String title;

    //帖子内容
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String content;

    //帖子的类型：0：普通，1：置顶
    @Field(type = FieldType.Integer)
    private int type;

    //帖子状态：0-正常; 1-精华; 2-拉黑;
    @Field(type = FieldType.Integer)
    private int status;

    //帖子创建时间
    @Field(type = FieldType.Date)
    private Date createTime;

    //评论数量
    @Field(type = FieldType.Integer)
    private int commentCount;

    //帖子分数
    @Field(type = FieldType.Double)
    private double score;

}
